package com.webwork.lims.transport.dataobject;

import java.util.ArrayList;
import java.util.List;

import com.webwork.lims.common.dataobject.SuperEnum;

public enum CarStatus implements SuperEnum {

	NOSET(SuperEnum.NOSET_CODE, SuperEnum.NOSET_MSG),

	/**
	 * 等待出车
	 */
	WAITING(1, "等待出车"),
	/**
	 * 运输中
	 */
	DELIVERY(2, "运输中");
	
	private Integer code;
	private String msg;
	
	private CarStatus(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	@Override
	public Integer getCode() {
		return code;
	}
	
	@Override
	public String getMsg() {
		return msg;
	}
	
	public static CarStatus[] useableValues() {
		List<CarStatus> ret = new ArrayList<CarStatus>();
		for (CarStatus o : CarStatus.values()) {
			if (o.code == CarStatus.NOSET_CODE) {
				continue;
			}
			ret.add(o);
		}
		return ret.toArray(new CarStatus[ret.size()]);
	}
	
	public static CarStatus fromCode(Integer code) {
		for (CarStatus o : CarStatus.values()) {
			if (o.code.equals(code)) {
				return o;
			}
		}
		throw new IllegalArgumentException(code.toString());
	}

}
